﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;


namespace SGArchiveSystem7x.Controllers
{
    public class ToJiController : Controller
    {
        // GET: ToJi
        public ActionResult Index()
        {
            return View();
        }


        /// <summary>
        /// 柱形图
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Get_ajaxArchivlist()
        {
            System.Data.DataTable dt = SGArchiveSystem7xDB.SQL.T_ArchiveAjSQL.GetArchivlist();
            int n = dt.Rows.Count;
            //string[] categories = new string[n];
            //int[] data = new int[n];
            string[] strs = new string[2];


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strs[1] += int.Parse(dt.Rows[i].ItemArray[0].ToString()) + ",";
                strs[0] += dt.Rows[i].ItemArray[1].ToString() + ",";
            }
            strs[0] = strs[0].TrimEnd(',');
            strs[1] = strs[1].TrimEnd(',');

            return strs[0] + "|" + strs[1];
        }

        /// <summary>
        /// 饼图
        /// </summary>
        /// <returns></returns>
        [HttpPost]
        public string Get_ajaxArchivlist1()
        {
            System.Data.DataTable dt = SGArchiveSystem7xDB.SQL.T_ArchiveAjSQL.GetArchivlist();
            int n = dt.Rows.Count;
            //string[] categories = new string[n];
            //int[] data = new int[n];
            string[] strs = new string[2];


            for (int i = 0; i < dt.Rows.Count; i++)
            {
                strs[0] += dt.Rows[i].ItemArray[1].ToString() + "  " + dt.Rows[i].ItemArray[0].ToString() + ",";
                strs[1] += dt.Rows[i].ItemArray[1].ToString() + ",";

            }
            strs[0] = strs[0].TrimEnd(',');
            strs[1] = strs[1].TrimEnd(',');

            return strs[0] + "|" + strs[1];
        }
    }
}